export const registerPlugin = (lf, pluginConfig) => {

	console.log(lf.extension.menu)
	lf.extension.menu.setMenuByType({
		type: "lf:defaultNodeMenu",
		menu: [],
	});
	lf.extension.menu.setMenuByType({
		type: "lf:defaultEdgeMenu",
		menu: [],
	});
	lf.extension.menu.setMenuByType({
		type: "lf:defaultGraphMenu",
		menu: [],
	});

	let menu = [
		{
			text: '删除',
			callback({edges, nodes}) {
				for (let node of nodes) {
					lf.removeNode(node.id)
				}
			},
		},
	];

	if (pluginConfig?.contextMenu?.selectionMenu) {
		for (let c of pluginConfig?.contextMenu?.selectionMenu) {
			menu.push(c)
		}
	}

	lf.extension.menu.setMenuByType({
		type: "lf:defaultSelectionMenu",
		menu: menu
	});

	lf.extension.control.addItem({
		key: 'mini-map',
		iconClass: 'custom-minimap',
		title: '导航',
		text: '导航',
		onClick: (lf, ev) => {
			const position = lf.getPointByClient(ev.x, ev.y)

			lf.extension.miniMap.show(
				position.domOverlayPosition.x - 150,
				position.domOverlayPosition.y + 35,
			)
		},
	});

	// lf.extension.control.addItem({
	// 	key: 'get-snapshot',
	// 	iconClass: 'get-snapshot',
	// 	title: '导出图片',
	// 	text: '导出图片',
	// 	onClick: async (lf, ev) => {
	// 		await lf.getSnapshot();
	// 	},
	// });
}
